/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trunk.view;

import java.awt.Component;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author yfoliveira
 */
public class FileChooser extends JFrame{

     
        public FileChooser() {           
                       
    }
        
    public  File getFile(){
        File fileName = new File("");
        long limite = 10485761;
      // display file dialog, so user can choose file to open
      while(limite>10485760){
         JOptionPane.showMessageDialog(this, "Tamanho maximo de arquivo para anexo 10mb");
        JFileChooser fileChooser = new JFileChooser();
      fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY );

      int result = fileChooser.showOpenDialog(this);

      // if user clicked Cancel button on dialog, return
      if ( result == JFileChooser.CANCEL_OPTION ){
          this.dispose();
         return null;
      }else{
      fileName = fileChooser.getSelectedFile(); // get selected file
      
      limite = fileName.length();
      }
      }
      return fileName;
      
   } // end method getFile

    
    
    
}
